<html>
<head><meta charset="utf-8"><title>Preventing auto-`DerefMut` of union fields · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Preventing.20auto-.60DerefMut.60.20of.20union.20fields.html">Preventing auto-`DerefMut` of union fields</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="207017214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Preventing%20auto-%60DerefMut%60%20of%20union%20fields/near/207017214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Preventing.20auto-.60DerefMut.60.20of.20union.20fields.html#207017214">(Aug 15 2020 at 11:16)</a>:</h4>
<p>We have an accepted RFC to <a href="https://github.com/rust-lang/rust/issues/55149#issuecomment-674380252">prevent auto-<code>DerefMut</code> of union fields</a>, but that hasn't been implemented yet. I have no idea where to even start with this, so help would be appreciated. :) Cc <span class="user-mention" data-user-id="116118">@Matthew Jasper</span></p>



<a name="207017625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Preventing%20auto-%60DerefMut%60%20of%20union%20fields/near/207017625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Preventing.20auto-.60DerefMut.60.20of.20union.20fields.html#207017625">(Aug 15 2020 at 11:28)</a>:</h4>
<p>Maybe check for union fields in <code>convert_place_derefs_to_mutable</code> and <code>convert_place_op_to_mutable</code> and emit an error there?</p>



<a name="207040055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Preventing%20auto-%60DerefMut%60%20of%20union%20fields/near/207040055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Preventing.20auto-.60DerefMut.60.20of.20union.20fields.html#207040055">(Aug 15 2020 at 21:25)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> hm, seems odd to first decide to autoderef and then bail out about that, but sure</p>



<a name="208426842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Preventing%20auto-%60DerefMut%60%20of%20union%20fields/near/208426842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Preventing.20auto-.60DerefMut.60.20of.20union.20fields.html#208426842">(Aug 29 2020 at 10:08)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> the PR has been up for almost 2 weeks: <a href="https://github.com/rust-lang/rust/pull/75584">https://github.com/rust-lang/rust/pull/75584</a>.<br>
do you think you'll be able to review it, and if not, any suggestions for who might?</p>



<a name="208477999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Preventing%20auto-%60DerefMut%60%20of%20union%20fields/near/208477999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Preventing.20auto-.60DerefMut.60.20of.20union.20fields.html#208477999">(Aug 30 2020 at 10:11)</a>:</h4>
<p>Yes, sorry for taking so long.</p>



<a name="208479747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Preventing%20auto-%60DerefMut%60%20of%20union%20fields/near/208479747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Preventing.20auto-.60DerefMut.60.20of.20union.20fields.html#208479747">(Aug 30 2020 at 11:03)</a>:</h4>
<p>no worries, and thanks :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>